content.js ➔ ... ➔ $sendButton.click   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 9
rs 9.6666
1
/* eslint-env browser, jquery, webextensions */
2
3
var $sendButton = $("<a id=\"send-to-omnifocus\">Send to OmniFocus &raquo;</a>");
4
5
$(function () {
6
  // creates an OF task using the supplied ticket info
7
  function createTaskForTicket(ticket) {
8
    var message = {
9
      method: "createTask",
10
      params: {
11
        name: "[" + ticket.key + '] ' + ticket.summary,
12
        note: window.location.href + "\n\n" + ticket.description
13
      }
14
    };
15
16
    chrome.runtime.sendMessage(message, function (data) {
0 ignored issues
show
Bug introduced by
The variable chrome seems to be never declared. If this is a global, consider adding a /** global: chrome */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
17
      $('<iframe style="display:none">')
18
        .attr('src', data.url)
19
        .appendTo('body');
20
    });
21
  }
22
23
  $sendButton.prependTo("#viewissuesidebar");
24
25
  $sendButton.on('click', function (evt) {
26
    evt.preventDefault();
27
28
    createTaskForTicket({
29
      key: $("#key-val").text(),
30
      summary: $("#summary-val").text().replace(/\s+/, ' ').replace(/^\s*(\S.+\S)\s*$/, '$1'),
31
      description: $("#description-val").html()
32
    });
33
  });
34
});
35